package com.health.userbackstage.exception.handler;

import com.health.userbackstage.exception.BusinessException;
import com.health.userbackstage.pojo.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author ASUS
 * @Date 2023/8/15 15:28
 * @Version 1.0
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result globalException(Exception e){
        e.printStackTrace();
        return Result.error();
    }

    @ExceptionHandler(BusinessException.class)
    public Result businessException(BusinessException be){
        return Result.error(be.getBe());
    }
}
